package com.cll.netty.netty.heartbeat;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.IdleStateEvent;

public class MyServerHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if(evt instanceof IdleStateEvent){
            IdleStateEvent idleStateEvent = (IdleStateEvent) evt;
            String s = "";
            switch (idleStateEvent.state()) {
                case READER_IDLE:
                    s = "读空闲";
                    break;
                case WRITER_IDLE:
                    s = "写空闲";
                    break;
                case ALL_IDLE:
                    s = "读写空闲";
                    break;

            }
            System.out.println(ctx.channel().remoteAddress() +"---超时时间-------"+ s );
        }
    }
}
